package com.android.hamster.games;

import java.util.List;

import android.graphics.Color;

import com.android.hamster.framework.Game;
import com.android.hamster.framework.Graphics;
import com.android.hamster.framework.Screen;
import com.android.hamster.framework.Input.TouchEvent;

public class SampleScreen extends Screen {
	Graphics graphics;
	String message = "Touch Screen";

	public SampleScreen(Game game) {
		super(game);
		graphics = game.getGraphics();
	}

	@Override
	public void update(float deltaTime) {

		List<TouchEvent> touchEvents = game.getInput().getTouchEvents();
		int len = touchEvents.size();
		for (int i = 0; i < len; i++) {
			TouchEvent event = touchEvents.get(i);
			if (event.type == TouchEvent.TOUCH_DOWN) {
				message = "Touching Down";
			}
			if (event.type == TouchEvent.TOUCH_DRAGGED) {
				message = "Dragging Finger";
			}
			if (event.type == TouchEvent.TOUCH_UP) {
				message = "Released Touch";

				if (event.x < 60 && event.y > 440) {
					game.setScreen(new Menu(game));
				}

			}
		}
	}

	@Override
	public void present(float deltaTime) {

		graphics.drawBackground(Color.BLACK); // background

		graphics.filledRectangle(20, 30, 50, 50, Color.BLUE); // 1st Square
		graphics.outlineRectangle(90, 30, 50, 50, 1, Color.GRAY); // 2nd Square
		graphics.outlineRectangle(160, 30, 50, 50, 5, Color.GRAY); // 3rd Square
		graphics.filledRectangle(230, 30, 50, 50, Color.BLUE);// 4th Square
		graphics.outlineRectangle(230, 30, 50, 50, 3, Color.GRAY); // 5th Square

		graphics.drawCircle(50, 120, 30, Color.YELLOW); // Circle

		graphics.drawLine(100, 100, 100, 150, Color.GREEN); // 1st vertical line
		graphics.drawLine(150, 100, 150, 150, Color.BLUE); // 2nd Vertical line
		graphics.drawLine(100, 100, 150, 100, Color.RED); // Horizontal line

		graphics.filledRectangle(0, 440, 60, 40, Color.DKGRAY); // Menu 
		graphics.outlineRectangle(0, 440, 60, 40, 3, Color.WHITE); // Menu
		graphics.drawText("Menu", 30, 470, 18, Color.WHITE); // Menu

		graphics.drawText(message, 160, 240, 32, Color.WHITE); // Message

	}

	@Override
	public void pause() {
	}

	@Override
	public void resume() {
	}

	@Override
	public void dispose() {
	}

}
